<%@page import="model.bean.TinBao"%>
<%@page import="model.bean.Canbo"%>
<%@page import="java.util.ArrayList"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	String uName = (String) request.getSession().getAttribute("uName");
	String role = (String) request.getSession().getAttribute("role");	
	if((uName == null) || !("admin".equals(role) || !"user".endsWith(role))) {
		response.sendRedirect("login.jsp");
	}
%> 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="UTF-8">
<title>ĐỒ ÁN TỐT NGHIỆP</title>
<meta
	content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no'
	name='viewport'>
<!-- bootstrap 3.0.2 -->
<link href="css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<!-- font Awesome -->
<link href="css/font-awesome.min.css" rel="stylesheet" type="text/css" />
<!-- Ionicons -->
<link href="css/ionicons.min.css" rel="stylesheet" type="text/css" />
<!-- Morris chart -->
<link href="css/morris/morris.css" rel="stylesheet" type="text/css" />
<!-- jvectormap -->
<link href="css/jvectormap/jquery-jvectormap-1.2.2.css" rel="stylesheet"
	type="text/css" />
<!-- Date Picker -->
<link href="css/datepicker/datepicker3.css" rel="stylesheet"
	type="text/css" />
<!-- Daterange picker -->
<link href="css/daterangepicker/daterangepicker-bs3.css"
	rel="stylesheet" type="text/css" />
<!-- bootstrap wysihtml5 - text editor -->
<link href="css/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css"
	rel="stylesheet" type="text/css" />
<!-- Theme style -->
<link href="css/AdminLTE.css" rel="stylesheet" type="text/css" />
<link href="mycss/popup.css" rel="stylesheet" type="text/css" />
</head>
<body class="skin-blue">

	<%
		ArrayList<Canbo> dsCanbo = (ArrayList<Canbo>)request.getAttribute("dsCanBo");
		TinBao tb = (TinBao)request.getAttribute("tinBao");
		String them = (String)request.getAttribute("them");
		if(tb == null) {
			tb = new TinBao();
		}
	%>
	<!-- header logo: style can be found in header.less -->
	<%@ include file="header.jsp"%>

	<div class="wrapper row-offcanvas row-offcanvas-left">
		<!-- Left side column. contains the logo and sidebar -->
		<%@ include file="menu.jsp"%>

		<!-- Right side column. Contains the navbar and content of the page -->
		<aside class="right-side"> <!-- Content Header (Page header) -->
		<section class="content-header">
		<h1>Quản lý tin báo</h1>
		<ol class="breadcrumb">
			<li><a href="index.jsp"><i class="fa fa-dashboard"></i>Trang
					chủ</a></li>
			<li><a href="#">Quản lý tin báo</a></li>
			<li class="active">cập nhật</li>
		</ol>
		</section> <!-- Main content --> <section class="content">
		<div class="col-md-7">

			<%
				if ("true".equals(them)) {
			%>
			<div class="alert alert-success alert-dismissable">
				<i class="fa fa-info"></i>
				<button type="button" class="close" data-dismiss="alert"
					aria-hidden="true">×</button>
				<b>Thông báo: </b> Thêm mới tin báo thành công!
			</div>
			<%
				}
			%>

			<%
				if ("false".equals(them)) {
			%>
			<div class="alert alert-danger alert-dismissable">
				<i class="fa fa-info"></i>
				<button type="button" class="close" data-dismiss="alert"
					aria-hidden="true">×</button>
				<b>Lỗi kết nối: </b> Thêm mới không thành công!
			</div>
			<%
				}
			%>
		</div>
		<div class="row">
			<!-- left column -->
			<div class="col-md-12">
				<!-- general form elements -->
				<div class="box box-primary">
					<!-- /.box-header -->
					<!-- form start -->
					<form action="TinBaoServlet" method="post" name="myform">
						<div class="box-body">
							<div class="form-group">
								<div class="col-md-4">
									<label>Cán bộ:</label>
									<div class="input-group">
										<div class="input-group-addon">
											<i class="fa fa-arrow-circle-down"></i>
										</div>
										<select class="form-control" name="idcb" id="idcb">
											<option value="<%=tb.getIdCanbo()%>" selected="selected"><%=tb.getTenCanbo()%></option>
											<%
												if(dsCanbo != null) {
														for(Canbo cb : dsCanbo) {	
															if(!cb.getIdCanbo().equals(tb.getIdCanbo())) {
											%>
											<option value="<%=cb.getIdCanbo()%>"><%=cb.getTenCanbo()%></option>
											<%
												} 	}																																																																												}
											%>
										</select>
									</div>
									<label>Ngày tiếp nhận:</label>
									<div class="input-group">
										<div class="input-group-addon">
											<i class="fa fa-clock-o"></i>
										</div>
										<input class="form-control" type="text"
											placeholder="Click chọn ngày tháng" id="datepicker"
											value="<%=tb.getThoiGian()%>" name="thoigian">
									</div>
									<label>Tiến độ:</label>
									<div class="input-group">
										<div class="input-group-addon">
											<i class="fa fa-arrow-circle-down"></i>
										</div>
										<select class="form-control" name="tiendoGQ" id="tiendoGQ">
											<%
												if("1".equals(tb.getTienDoGQ())) {
											%>
											<option value="1" selected="selected">Đã giải quyết</option>
											<option value="0">Chưa giải quyết</option>
											<%
												}
											%>
											<%
												if("0".equals(tb.getTienDoGQ())) {
											%>
											<option value="1" >Đã giải quyết</option>
											<option value="0" selected="selected">Chưa giải quyết</option>
											<%
												}
											%>
										</select>
									</div>
									<label>Số CMND:</label>
									<div class="input-group">
										<div class="input-group-addon">
											<i class="fa fa-info"></i>
										</div>
										<input type="text" class="form-control pull-right" value="<%=tb.getCmnd() %>"
											type="number" id="cmnd" placeholder="Nhập số CMND"
											name="cmnd">
									</div>
								</div>
								<div class="col-md-8">
									<label>Người báo tin:</label>
									<div class="input-group">
										<div class="input-group-addon">
											<i class="fa fa-info"></i>
										</div>
										<input type="text" class="form-control pull-right"
											id="nguoibaotin" placeholder="Nhập số cmnd"
											name="nguoibaotin" value="<%=tb.getNguoiBaoTin()%>">
									</div>
									<label>Địa chỉ:</label>
									<div class="input-group">
										<div class="input-group-addon">
											<i class="fa fa-info"></i>
										</div>
										<input type="text" class="form-control pull-right" id="diachi"
											placeholder="Nhập địa chỉ" name="diachi" value="<%=tb.getDiaChi()%>">
									</div>
									<label>Nội dung:</label>
									<div class='box box-info'>
										<div class='box-header'>
											<!-- tools box -->
											<div class="pull-right box-tools">
												<button class="btn btn-info btn-sm" data-widget='collapse'
													data-toggle="tooltip" title="Thủ nhỏ">
													<i class="fa fa-minus"></i>
												</button>
											</div>
											<!-- /. tools -->
										</div>
										<!-- /.box-header -->
										<div class='box-body pad'>
											<textarea id="noidung" name="noidung" rows="10" cols="80"
												placeholder="Nội dung..."><%=tb.getNoidung() %></textarea>
										</div>
									</div>
									<!-- /.box -->
									<!-- /.form group -->
								</div>
							</div>
						</div>
					</form>
					<div class="box-footer">
						<button type="submit" class="btn btn-success" onclick="kt()">Cập nhật</button>
						<a href="TinBaoServlet?dsTinbao" class="btn btn-primary">Bỏ
							qua</a>
					</div>
				</div>
				<!-- popup -->
				<div id="element_to_pop_up">
					<a class="button b-close">X</a>
					<h3>Vui lòng nhập đầy đủ thông tin!</h3>
					<a href="#" onclick="closepopup()"><span
						class="button small pop1">OK</span></a>
				</div>
				<!-- Element to pop up -->
				<div id="element_to_pop_up2">
					<a class="button b-close">X</a>
					<h4>Bạn có chắc chắn muốn cập nhập thông tin không?</h4>
					<a href="#" onclick="sua()"><span class="button small pop1">Đồng
							ý</span></a> <a href="#" onclick="popupclose2()"><span
						class="button small pop1">Hủy</span></a>
				</div>
			</div>
			<!-- /.box -->
			<!-- Form Element sizes -->
		</div>
		<!--/.col (left) -->
	</div>
	<!-- /.row -->
	</section>
	<!-- /.content -->
	</aside>
	<!-- /.right-side -->
	</div>
	<!-- ./wrapper -->
	<!-- jQuery 2.0.2 -->
	<script src="js/jquery.min.js"></script>
	<!-- Bootstrap -->
	<script src="js/bootstrap.min.js" type="text/javascript"></script>
	<!-- InputMask -->
	<script src="js/plugins/input-mask/jquery.inputmask.js"
		type="text/javascript"></script>
	<script src="js/plugins/input-mask/jquery.inputmask.date.extensions.js"
		type="text/javascript"></script>
	<script src="js/plugins/input-mask/jquery.inputmask.extensions.js"
		type="text/javascript"></script>
	<!-- date-range-picker -->
	<script src="js/plugins/daterangepicker/daterangepicker.js"
		type="text/javascript"></script>
	<!-- bootstrap color picker -->
	<script src="js/plugins/colorpicker/bootstrap-colorpicker.min.js"
		type="text/javascript"></script>
	<!-- bootstrap time picker -->
	<script src="js/plugins/timepicker/bootstrap-timepicker.min.js"
		type="text/javascript"></script>
	<!-- bootstrap datepicker -->
	<script src="js/plugins/datepicker/bootstrap-datepicker.js"
		type="text/javascript"></script>
	<!-- AdminLTE App -->
	<script src="js/AdminLTE/app.js" type="text/javascript"></script>
	<!-- AdminLTE for demo purposes -->
	<script src="js/AdminLTE/demo.js" type="text/javascript"></script>
	<!-- popup -->
	<script src="myjs/bpopup.min.js" type="text/javascript"></script>

	<!-- CK Editor -->
	<script src="js/plugins/ckeditor/ckeditor.js" type="text/javascript"></script>
	<!-- Bootstrap WYSIHTML5 -->
	<script
		src="js/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min.js"
		type="text/javascript"></script>
	<!-- Page script -->
	<script>
		//Date range picker
		$('#reservation').daterangepicker({
			format : 'YYYY-MM-DD'
		});
		$('#reservation2').daterangepicker({
			format : 'YYYY-MM-DD'
		});

		$(function() {
			$("#datepicker").datepicker({
				format : 'yyyy-mm-dd'
			});
		});
		$(function() {
			$("#datepicker2").datepicker({
				format : 'yyyy-mm-dd'
			});
		});

		function kt() {

			var idcb = document.getElementById('idcb').value;
			var tiendoGQ = document.getElementById('tiendoGQ').value;
			var cmnd = document.getElementById('cmnd').value;
			var datepicker = document.getElementById('datepicker').value;
			var nguoibaotin = document.getElementById('nguoibaotin').value;
			var noidung = CKEDITOR.instances.noidung.getData();

			if (idcb == "" || tiendoGQ == "" || cmnd == "" || datepicker == ""
					|| nguoibaotin == "" || noidung == "") {
				$('#element_to_pop_up').bPopup({
					speed : 650,
					transition : 'slideIn',
					transitionClose : 'slideBack'
				});
			} else {
				$('#element_to_pop_up2').bPopup({
					speed : 650,
					transition : 'slideIn',
					transitionClose : 'slideBack'
				});
			}
		}

		function sua() {
			document.forms["myform"].submit();
		}

		function closepopup() {
			$('#element_to_pop_up').bPopup().close();
		}

		function closepopup2() {
			$('#element_to_pop_up2').bPopup().close();
		}

		$(function() {
			// Replace the <textarea id="editor1"> with a CKEditor
			// instance, using default configuration.
			CKEDITOR.replace('noidung');
			//bootstrap WYSIHTML5 - text editor
			$(".textarea").wysihtml5();
		});
	</script>
</body>
</html>